﻿using System;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SearchAggregator
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private async void btnSearch_Click(object sender, EventArgs e)
        {
            string keyword = txtKeyword.Text.Trim();
            if (string.IsNullOrWhiteSpace(keyword))
            {
                MessageBox.Show("未输入搜索词！");
                return;
            }

            // 清空结果
            txtBaidu.Text = "正在搜索 百度...";
            txtBing.Text = "正在搜索 Bing...";

            // 并发搜索
            var soTask = SearchEngineHelper.SearchSoAsync(keyword);
            var bingTask = SearchEngineHelper.SearchBingAsync(keyword);

            var results = await Task.WhenAll(soTask, bingTask);

            txtBaidu.Text = results[0];
            txtBing.Text = results[1];
        }

        private void lblBaidu_Click(object sender, EventArgs e)
        {

        }
    }
}

